#ifndef _RAMP_H_
#define _RAMP_H_

#include <vector>
#include "graphics/color.h"
namespace math
{
class Ramp
{
public:
	Ramp();
	~Ramp();

	float			GetValue(float Pos);
	void			AddValue(float Value, float Position);	
	void			Recalc();
	void			Set(Ramp* Input);
	void			Reset();

	unsigned short	size() { return (unsigned short)m_Values.size(); };
	void			GetByIndex(int Index, float& Value, float& Position);
private:
	struct	ValueInst
	{
		float		Value, Position;
		static bool SortValues(const ValueInst& A, const ValueInst& B)
		{
			return A.Position < B.Position;
		}
	};
	std::vector<ValueInst>	m_Values;
	static const unsigned int	RAMP_SIZE = 256;
	float						m_RampA[RAMP_SIZE];
};

class	ColorRamp
{
public:
	ColorRamp()
	{
		
	};

	static const int	CHANNELS = 4;
	COLOR			GetColor(float Position)
	{
		float	R = m_ColorA[0].GetValue(Position);
		float	G = m_ColorA[1].GetValue(Position);
		float	B = m_ColorA[2].GetValue(Position);
		float	A = m_ColorA[3].GetValue(Position);
		return ColorfRGBA(R, G, B, A);

	}
	void			AddColor(float R, float G, float B, float A, float Position)
	{
		m_ColorA[0].AddValue(R, Position);
		m_ColorA[1].AddValue(G, Position);
		m_ColorA[2].AddValue(B, Position);
		m_ColorA[3].AddValue(A, Position);
	}
	void			AddColor(COLOR c, float Position)
	{
		float	R = ColorGetRf(c);
		float	G = ColorGetGf(c);
		float	B = ColorGetBf(c);
		float	A = ColorGetAf(c);
		AddColor(R, G, B, A, Position);
	}
	void			Recalc()
	{
		for (int i=0; i<CHANNELS; i++)
			m_ColorA[i].Recalc();
	}	
	void			Reset()
	{
		for (int i=0; i<CHANNELS; i++)
			m_ColorA[i].Reset();
	}	
private:
	Ramp				m_ColorA[CHANNELS];
};
}

#endif // _RAMP_H_